<%@ page language="java" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="tag" prefix="PF" %>
<%@ taglib uri="doc" prefix="DOC" %>
<%--
  ~ This file Copyright (c) 2015. Walle.
  ~ (http://www.wallellen.com). All rights reserved.
  ~
  ~
  ~ This file is dual-licensed under both the
  ~ Walle Agreement (WA) and the GNU General Public License.
  ~ You may elect to use one or the other of these licenses.
  ~
  ~ This file is distributed in the hope that it will be
  ~ useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
  ~ implied warranty of MERCHANTABILITY or FITNESS FOR A
  ~ PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
  ~ Redistribution, except as permitted by whichever of the GPL
  ~ or WA you select, is prohibited.
  ~
  ~ 1. For the GPL license (GPL), you can redistribute and/or
  ~ modify this file under the terms of the GNU General
  ~ Public License, Version 3, as published by the Free Software
  ~ Foundation.  You should have received a copy of the GNU
  ~ General Public License, Version 3 along with this program;
  ~ if not, write to the Free Software Foundation, Inc., 51
  ~ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  ~
  ~ 2. For the Walle Agreement (WA), this file
  ~ and the accompanying materials are made available under the
  ~ terms of the WA which accompanies this distribution, and
  ~ is available at http://www.wallellen.com/agreement.html
  ~
  ~
  ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
  --%>

<!-- 如果是内容类型等于4小组首页，则在此处不提供任何操作功能 -->
<c:if test="${DOCE.doc.domtype!='4'}">
    <c:if test="${DOCE.doc.state=='2'||DOCE.doc.state=='3'}">
        <div class="alert alert-danger" role="alert">
            <span class=" glyphicon glyphicon-info-sign">[未审核,该文档未经过必要的审核请谨慎参考]</span>
        </div>
    </c:if>
    <div style="padding: 2px;">
        <c:if test="${USEROBJ!=null}">
            <c:if test="${ISENJOY}">
                <button type="button" id="disEnjoyId"
                        class="btn btn-default  btn-xs">
                    <span class="glyphicon glyphicon-star"></span>&nbsp;取消关注
                </button>
            </c:if>
            <c:if test="${!ISENJOY}">
                <button type="button" id="enjoyId" class="btn btn-default  btn-xs">
                    <span class="glyphicon glyphicon-star"></span>&nbsp;关注
                </button>
            </c:if>
            <DOC:canWriteIsShow docId="${DOCE.doc.id}">
                <button type="button" id="editTopButtonId"
                        class="btn btn-default  btn-xs">
                    <span class="glyphicon glyphicon-envelope"></span>&nbsp;修改
                </button>
            </DOC:canWriteIsShow>
            <DOC:canDelIsShow docId="${DOCE.doc.id}">
                <button type="button" id="delTopButtonId"
                        class="btn btn-default  btn-xs">
                    <span class="glyphicon glyphicon-envelope"></span>&nbsp;删除
                </button>
                <button type="button" id="publickButtonId"
                        class="btn btn-default  btn-xs">
                    <span class="glyphicon glyphicon-plane"></span>&nbsp;公开文档
                </button>
            </DOC:canDelIsShow>
        </c:if>
        <c:if test="${USEROBJ==null}">
            <button type="button" class="btn btn-default btn-xs"
                    disabled="disabled">
                <span class="glyphicon glyphicon-star"></span>&nbsp;登录后关注
            </button>
        </c:if>
        <h4 class="pull-right">
            &nbsp; <span class="label label-default" title="访问量"><span
                class="glyphicon glyphicon-hand-up"></span>&nbsp;${DOCE.runinfo.visitnum}</span>
        </h4>
        <h4 class="pull-right">
            &nbsp; <a href="webdoc/Pubmsg.do?docid=${DOCE.doc.id}"><span
                class="label label-info" title="评论"><span
                class="glyphicon glyphicon-comment"></span>&nbsp;${DOCE.runinfo.answeringnum}</span></a>
        </h4>
    </div>
</c:if>
<script type="text/javascript">
    $(function () {
        $('#editTopButtonId').bind('click', function () {
            window.location = basePath + 'know/edit.do?docid=${DOCE.doc.id}';
        });
        $('#delTopButtonId').bind(
                'click',
                function () {
                    if (confirm("删除后该知识将无法恢复，确定要删除吗？")) {
                        window.location = basePath
                                + 'webdoc/FLDelKnow.do?id=${DOCE.doc.id}';
                    }
                });
        $('#publickButtonId').bind(
                'click',
                function () {
                    if (confirm("是否要将该文档开放阅读和编辑权限，同时如果是小组文档将删除小组所有权？")) {
                        window.location = basePath
                                + 'webdoc/FLflyKnow.do?id=${DOCE.doc.id}';
                    }
                });
        //关注
        $('#enjoyId')
                .live(
                'click',
                function () {
                    $
                            .post(
                            'webdoc/enjoy.do?id=${DOCE.doc.id}',
                            function (flag) {
                                if (flag.commitType == '0') {
                                    alert('关注成功');
                                    var buttonStr = '<button type="button" id="disEnjoyId" class="btn btn-default  btn-xs"><span class="glyphicon glyphicon-star"></span>取消关注</button>';
                                    $('#enjoyId').before(
                                            buttonStr);
                                    $('#enjoyId').remove();
                                } else {
                                    alert('关注失败');
                                }
                            }, 'json');
                });
        //取消关注
        $('#disEnjoyId')
                .live(
                'click',
                function () {
                    $
                            .post(
                            'webdoc/FLunEnjoy.do?id=${DOCE.doc.id}',
                            function (flag) {
                                if (flag.commitType == '0') {
                                    alert('取消关注成功');
                                    var buttonStr = '<button type="button" id="enjoyId" class="btn btn-default  btn-xs"><span class="glyphicon glyphicon-star"></span>关注</button>';
                                    $('#disEnjoyId').before(
                                            buttonStr);
                                    $('#disEnjoyId').remove();
                                } else {
                                    alert('取消关注失败');
                                }
                            }, 'json');
                });
    });
</script>